package Cantella::DJabberd::Web::UI::ViewPort::Field::String::Fragment;

use Reaction::Class;
extends 'Reaction::UI::ViewPort::Field::String';
has max_length => (is => 'rw', isa => 'Int', required => 1, default => sub { 80 });

sub _build_layout { 'field/string' };

around _build_value_string => sub { 
  my $super = shift;
  my $self = $_[0];
  my $string = $super->(@_);
  my $max_len = $self->max_length;
  if(length($string) > $max_len){
    return substr( $string, 0, $max_len - 3 ) . '...';
  } else {
    return $string;
  }
};

__PACKAGE__->meta->make_immutable;

1;

